package com.qf.kady.ssm.interceptor;

import org.springframework.util.ObjectUtils;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author ghy
 * @version 1.0
 */
public class PermissionInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        Object loginName = request.getSession().getAttribute("logUserInfo");
        if(ObjectUtils.isEmpty(loginName)) {
            //没登录，去登录页
            response.sendRedirect(request.getContextPath() + "/");
            return false;
        }
        return true;
    }
}
